<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>tts</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">

	</head>

	<script type="text/javascript">

var lang = 2;
//var ver = " 5.5.1, Jan 25 2013";

var userid = <%=request.getParameter("userid")%>;
var alias = <%=request.getParameter("alias")%>;
</script>
<script type="text/javascript">
function createVoice() {
	if (f.alias.value == "" || f.alias.value == " ") {
		alert("请输入用户名");
	} else {
		var ocx = document.getElementById("fidevOcx");
		var obj = document.getElementById("filePath");
		if (ocx && obj) {
			obj.innerHTML = ocx.OutSpeechFile(f.alias.value);
			readVoice();
		} else
			alert("控件初始化失败");
	}
}

function readVoice() {
	if (f.alias.value == "" || f.alias.value == " ") {
		alert("请输入用户名");
	} else if (!name_verify(f.alias.value)) {
		alert("用户名输入错误，请重新输入 !");
	} else {
		var ocx = document.getElementById("fidevOcx");
		ocx.ListenOutFile();
	}
}

function checkSubmit() {
	if (f.alias.value == "") {
		alert("请输入用户名!");
		f.alias.focus();
		return false;
	} else if (f.alias.value == " ") {
		alert("用户名输入错误，请重新输入 !");
		f.alias.focus();
		return false;
	}

	if (f.voiceFile.value == "") {
		alert("请输入语音文件!");
		f.voiceFile.focus();
		return false;
	} else {
		var name = f.voiceFile.value;
		if (name.indexOf(".wav") == -1 && name.indexOf(".WAV") == -1) {
			alert("请输入有效的语音文件!");
			f.voiceFile.focus();
			return false;
		}
	}

	return true;
}
function name_verify(name_string)
{
	var c;
	var n = 0;
	var ch = "\'\"/\\<>*#|&:?";
	
	if (name_string.length == 0 )
		return false;
	for(n = 0; n < name_string.length; n ++ ){
		c = name_string.charAt(n);
		if(c==' ') continue;
		break;
	}
//alert(n);
	if(n>=name_string.length) return false;
	
	for (var i = n; i < name_string.length; i++){
		c = name_string.charAt(i);
		if (ch.indexOf(c) != -1){
			return false;
		}
	}

	return true;	
}
</script>
	<body class="main-con" onLoad="createVoice();">

		<div class="cont_right_cont">

			<script type="text/javascript">

document.writeln("<H3>" + ("生成并上传语音报姓名") + "</H3>");

document
		.writeln("<FORM name='f' method=post action='http://192.168.2.25/tts.asp' onSubmit='return checkSubmit();'  enctype='multipart/form-data'>");

document.writeln("<TABLE  class='textinput'>");

document.writeln("<TR style='display:none'>");
document.writeln("  <TD>" + ("用户ID") + ": </TD>");
document
		.writeln("  <TD align=left><INPUT type=text name='userid' class='text' size=20 maxlength=20 value="
				+ userid + "></TD>");
document.writeln("</TR>");

document.writeln("<TR>");
document.writeln("  <TD width=60>" + ("用户名") + ": </TD>");
document
		.writeln("  <TD align=left><INPUT type=text name='alias' class='text' size=17 maxlength=17 value=\""
				+ alias + "\"  onChange=createVoice()>");
document.writeln("  <INPUT type=button value='" + ("试听")
		+ "' onClick='readVoice();'></TD>");
document.writeln("</TR>");

document.writeln("<TR style='display:none'>");
document.writeln("  <TD colspan=2>");
document
		.writeln("<DIV style='position:relative;top:3px'>&nbsp;<OBJECT id='FidevOcx' classid='clsid:2C8D62BF-02DC-44B8-99A8-805B26CD52E7' codebase='http://192.168.2.25/fidev.cab#version=1,0,0,1' width=100 height=100><SPAN style='color:red'>&nbsp;&nbsp;&nbsp;&nbsp;"
				+ ("ActiveX插件没有安装。请检查您的浏览器的安全设置。") + "</SPAN></OBJECT></DIV>");
document.writeln("  </TD>");
document.writeln("</TR>");

document.writeln("  <TR>");
document.writeln("    <TD colspan=2>" + ("自动生成的语音文件路径") + ": &nbsp;");
document.writeln("    <SPAN id=filePath>&nbsp;</SPAN></TD>");
document.writeln("  </TR>");

document.writeln("  <TR><TD>&nbsp;</TD></TR>");

document.writeln("  <TR>");
document.writeln("    <TD>" + ("上传的语音文件(最大64KB)") + ": &nbsp;</TD>");
document
		.writeln("   <TD align=left><input type=file id='voiceFile' name='voiceFile' size=60 contenteditable='false'></TD>");
document.writeln("  </TR>");

document.writeln("</TABLE>");

document.writeln("<TABLE class='submit'>");
document.writeln("    <TR>");
document
		.writeln("        <TD><input type=submit class='button' name='save' id='save' value='"
				+ ("上传") + "'></TD>");
document
		.writeln("        <TD><input type=reset class='button' id='reset' value='"
				+ ("取消") + "'></TD>");
document.writeln("    </TR>");
document.writeln("</TABLE>");

document.writeln("</FORM>");

document.writeln("<BR><BR><HR><BR>");

if (0)
	document.writeln("<A href=\"tts/tts.exe\">" + ("点击这里下载中英文发音引擎")
			+ "</A><BR>");
else
	document
			.writeln("<A href=\"http://download.iciba.com/pwpe/girl_xiaokun.exe\">"
					+ ("点击这里下载中英文发音引擎") + "</A><BR>");
</script>

		</div>
	</body>
</html>
